package com.iteaj.iot.serial;

import com.iteaj.iot.ProtocolHandle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public interface SerialEventProtocolHandle extends ProtocolHandle<SerialEventProtocol> {

    SerialEventProtocolHandle LOGGER_HANDLE = new LoggerSerialProtocolHandle();

    @Override
    default Object handle(SerialEventProtocol protocol) {
        this.doHandle(protocol);
        return null;
    }

    void doHandle(SerialEventProtocol protocol);

    class LoggerSerialProtocolHandle implements SerialEventProtocolHandle {

        private Logger logger = LoggerFactory.getLogger(LoggerSerialProtocolHandle.class);

        @Override
        public void doHandle(SerialEventProtocol protocol) {
            if(logger.isInfoEnabled()) {
//                SerialClient client = protocol.getIotClient();
//                logger.info("串口 监听到数据 - 串口: {} - 数据: {}", client.getConnectProperties());
            }
        }
    }
}
